package com.vtron.dbase.models;

import lombok.Data;

/**
 * @数据关系
 * @date : 2021/12/29 18:54
 * @author: 忻龙彪
 */
@Data
public class DbRelationship {
    /**
     * @字段名
     */
    private String fieldName;
    /**
     * @值
     */
    private String value;
    /**
     * @运算符
     */
    private String operation;
    /**
     * @分割符
     */
    private DbSeparator separator = DbSeparator.AND;
    /**
     * @条件
     */
    private String where;

    public DbRelationship(String where) {
        this.where = where;
    }

    public DbRelationship(String fieldName, String value) {
        this(fieldName, "=", value, DbSeparator.AND);
    }

    public DbRelationship(String fieldName, String operation, String value) {
        this(fieldName, operation,value, DbSeparator.AND);
    }

    public DbRelationship(String fieldName, String operation, String value, DbSeparator separator) {
        this.fieldName = fieldName;
        this.value = value;
        this.operation = operation;
        this.separator = separator;
    }

    public static DbRelationship where(String where) {
        return new DbRelationship(where);
    }

    public static DbRelationship where(String where, DbSeparator separator) {
        DbRelationship ship = new DbRelationship(where);
        ship.setSeparator(separator);
        return ship;
    }
}
